package com.redepronik.negosys.invfac.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * The persistent class for the traspaso database table.
 * 
 */
@Entity
@Table(schema = "invfac", name = "traspaso")
@NamedQuery(name = "Traspaso.findAll", query = "SELECT t FROM Traspaso t")
public class Traspaso implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "TRASPASO_TRASPASOID_GENERATOR", sequenceName = "INVFAC.TRASPASO_TRASPASOID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TRASPASO_TRASPASOID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer traspasoid;

	@Column(nullable = false, length = 25)
	private String codigodocumento;

	@Column(nullable = false, length = 200)
	private String detalle;

	@Column(nullable = false)
	private Timestamp fecha;

	@Column(nullable = false)
	private Boolean realizado;

	// bi-directional many-to-one association to Detalletraspaso
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "traspaso")
	private List<Detalletraspaso> detalletraspasos;

	// bi-directional many-to-one association to Bodega
	@ManyToOne
	@JoinColumn(name = "bodegaorigenid", nullable = false)
	private Bodega bodega1;

	// bi-directional many-to-one association to Bodega
	@ManyToOne
	@JoinColumn(name = "bodegadestinoid", nullable = false)
	private Bodega bodega2;

	// bi-directional many-to-one association to Tipodocumento
	@ManyToOne
	@JoinColumn(name = "tipodocumentoid", nullable = false)
	private Tipodocumento tipodocumento;

	public Traspaso() {
	}

	public Detalletraspaso addDetalletraspaso(Detalletraspaso detalletraspaso) {
		getDetalletraspasos().add(detalletraspaso);
		detalletraspaso.setTraspaso(this);

		return detalletraspaso;
	}

	public Bodega getBodega1() {
		return this.bodega1;
	}

	public Bodega getBodega2() {
		return this.bodega2;
	}

	public String getCodigodocumento() {
		return this.codigodocumento;
	}

	public String getDetalle() {
		return this.detalle;
	}

	public List<Detalletraspaso> getDetalletraspasos() {
		return this.detalletraspasos;
	}

	public Timestamp getFecha() {
		return this.fecha;
	}

	public Boolean getRealizado() {
		return this.realizado;
	}

	public Tipodocumento getTipodocumento() {
		return this.tipodocumento;
	}

	public Integer getTraspasoid() {
		return this.traspasoid;
	}

	public Detalletraspaso removeDetalletraspaso(Detalletraspaso detalletraspaso) {
		getDetalletraspasos().remove(detalletraspaso);
		detalletraspaso.setTraspaso(null);

		return detalletraspaso;
	}

	public void setBodega1(Bodega bodega1) {
		this.bodega1 = bodega1;
	}

	public void setBodega2(Bodega bodega2) {
		this.bodega2 = bodega2;
	}

	public void setCodigodocumento(String codigodocumento) {
		this.codigodocumento = codigodocumento;
	}

	public void setDetalle(String detalle) {
		this.detalle = detalle;
	}

	public void setDetalletraspasos(List<Detalletraspaso> detalletraspasos) {
		this.detalletraspasos = detalletraspasos;
	}

	public void setFecha(Timestamp fecha) {
		this.fecha = fecha;
	}

	public void setRealizado(Boolean realizado) {
		this.realizado = realizado;
	}

	public void setTipodocumento(Tipodocumento tipodocumento) {
		this.tipodocumento = tipodocumento;
	}

	public void setTraspasoid(Integer traspasoid) {
		this.traspasoid = traspasoid;
	}

}